<template>
  <el-dialog title="查看备注" :visible.sync="dialogVisible" width="1000px">
    <el-table :data="tableData" border>
      <el-table-column label="备注信息" prop="remark" />
      <el-table-column align="center" label="操作人员" prop="username" width="120" />
      <el-table-column align="center" label="时间" prop="create_time" />
    </el-table>
    <custom-page ref="customPage" :total="total" @getList="getList" />
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dialogVisible = false">关闭</el-button>
      <el-button type="warning" @click="add">添加备注</el-button>
    </div>
    <add-dialog ref="addDialog" :order-id="orderId" :which-period="whichPeriod" @getList="getList" />
  </el-dialog>
</template>

<script>
import { getOrderRemark } from '@/api/finance'
import customPage from '@/components/customPage'
import addDialog from './addRemark'
export default {
  components: { customPage, addDialog },
  // props: ['orderId', 'whichPeriod'],
  props: {
    orderId: {
      type: String,
      default: ''
    },
    whichPeriod: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      dialogVisible: false,
      tableData: [],
      total: 0
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getList()
        })
      }
    }
  },
  methods: {
    add() {
      this.$refs.addDialog.dialogVisible = true
    },
    getList() {
      const { page, pageSize } = this.$refs.customPage
      getOrderRemark({
        page,
        pageSize,
        orderId: this.orderId
      }).then(res => {
        this.tableData = res.data || []
        this.total = res.total
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
